#include <gmlib/err.h>
#include <gmlib/math.h>
#include <stdlib.h>

static char*(prime[]) = {
    "1127826100375682744707123837403", "843395065860013637848845944023",
    "819976235452070558961496369673",  "729939161485116766337267735417",
    "1109781587451764591313384664223", "666037193858862567715192134967",
    "666148856286976573638580958711",  "1159443632994848758133616157757",
    "1217731673435006552522005990679", "878863513795874044978004973883",
    "1049600993746357960618530178211", "832959254749822892299000397791",
    "647686544102834029520003363467",  "1136360879648385613909600037821",
    "678682642404404280982816547047",  "1118322485929241340614630624977",
    "1121776521376205805776849965363", "1165158342761613273266805912409",
    "942861557477046973569650278063",  "1119591521297316040929095515631",
};

void test_math_prime() {
    BINT x;
    for (int i = 0; i < sizeof(prime) / sizeof(char*); i++) {
        try_goto(bint_from_str(&x, prime[i], 10));
        int status = 0;
        try_goto(bint_is_prime(&x, &status));
        if (status == 0) {
            ERR_LOG("Err in bint_is_prime");
            goto error;
        }
    }
    return;

error:
    exit(-1);
}
